package nz.ac.massey.whatiscomputerscience.implementation.applet;

import java.applet.Applet;
import java.awt.Color;
import java.awt.Font;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;

/**
 * This is the applet that will be used to display the nifty graphics we will produce.
 * 
 * The general and very vague use case is (taken from project description):
 * 
 * Users watch as an image is broken down into component triangles
 * The triangulated image's triangles are further broken down
 * to reduce the length of individual lines (distance between connected points in the image)
 * From here the image can be warped (possibly in 3 dimensions)
 * In particular the implementation of this behaviour is visible to the user
 * i.e. the triangles and other structures can be revealed or hidden.
 * 
 * Intended to be used as a learning tool.  To promote interest among young people.
 * 
 * @author Francis Stephens
 */
public class NiftyGraphics extends Applet
{
	/**
	 * Automaticall generated ID courtesy of Eclipse
	 */
	private static final long serialVersionUID = -2570892755174714777L;
	
	/**
	 * Initialises the applet
	 * Currently empty
	 * 
	 * @see java.applet.Applet#init( )
	 */
	@Override
	public void init( )
	{
		// Currently empty
	}
	
	/**
	 * Used if applet is stopped
	 * currently empty
	 * 
	 * @see java.applet.Applet#stop( )
	 */
	@Override
	public void stop( )
	{
		// Currently empty
	} 
	
	/**
	 * Method invoked each time applet is rendered
	 * currently writes "Hello World"
	 * 
	 * @see java.awt.Container#paint( java.awt.Graphics )
	 */
	@Override
	public void paint( Graphics g )
	{
		String message = "Hello World!";
		Graphics2D g2 = (Graphics2D)g;
		g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
		Font f = new Font("Arial",Font.BOLD|Font.ITALIC,32);
		g2.setFont(f);
		g2.setPaint(new GradientPaint(0,20,Color.YELLOW,0,70,Color.RED));
		g.drawString(message,5, 50 );
	}
}